﻿namespace LeetCodeProject._0001_1000._001_100._21_30._026;

public class Solution
{
    public int RemoveDuplicates(int[] nums)
    {
        if (nums == null || nums.Length == 0)
            return 0;
        int result = 0;
        var ni = nums[0];
        for (int j = 1; j < nums.Length; j++)
        {
            var nj = nums[j];
            if (ni != nj)
                ni = nums[++result] = nj;
        }

        return result + 1;
    }
}